package es.udc.emarketapp.emarket.model.orderLine.dao;

import es.udc.fbellas.j2ee.util.configuration.ConfigurationParametersManager;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;


public final class SQLOrderLineDAOFactory {
    private final static String DAO_CLASS_NAME_PARAMETER = "SQLOrderLineDAOFactory/daoClassName";
    private final static Class daoClass = getDAOClass();

    private SQLOrderLineDAOFactory() {}
    
    private static Class getDAOClass() {
        Class theClass = null;
        try {
            String daoClassName = ConfigurationParametersManager.getParameter(DAO_CLASS_NAME_PARAMETER);
            theClass = Class.forName(daoClassName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theClass;
    }
  
    public static SQLOrderLineDAO getDAO()
       throws InternalErrorException {
       try {
           return (SQLOrderLineDAO) daoClass.newInstance();
       } catch (Exception e) {
           throw new InternalErrorException(e);
       }
  }
}
